GBML manual / Motion

move_bounce

Moves this instance by its own hsp/vsp against the current room’s collision; a blocked axis REVERSES that axis’s speed instead of merely stopping.

Syntax

move_bounce()

Returns

Nothing.

Description

Moves this instance by its own hsp/vsp against the current room's own collision; a blocked axis REVERSES that axis's speed instead of merely stopping it the way move_slide would. Drives off hsp/vsp directly rather than an arbitrary offset - "bounce" only means something for a value that persists from call to call, unlike move_slide's explicit dx/dy argument.

Example

move_bounce();

Call this every step once this instance has some hsp/vsp to move by - each blocked axis reverses instead of stopping, so a single push keeps ricocheting call after call, the shape a bouncing projectile or a Breakout-style ball wants.

On the GBA

Drives off hsp/vsp directly (not an arbitrary dx/dy, unlike move_slide) - "bounce" only means something for a value that persists past this one call. It reverses vsp on real contact with something solid. One interaction worth knowing, shared with move_slide’s own note on the automatic per-frame Movement phase: that phase ALWAYS applies hsp/vsp to position too, every frame, on top of whatever a Step event’s own move_bounce() call just did - unlike move_slide (which takes an explicit dx/dy and expects hsp/vsp to stay 0), move_bounce is MEANT to leave hsp/vsp persisting, so an object that calls it every Step effectively moves by hsp/vsp twice most frames (once inside move_bounce, once in the automatic phase right after) - not a bug, just something to expect rather than be surprised by if the resulting speed looks doubled.

See also: move_slidehspvsp